# Contributor: Hidde van der Heide <hvanderheide@nexuz.net>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=opendmarc
pkgver=1.3.2
pkgrel=0
pkgdesc="A free open source implementation of the DMARC specification"
url="http://www.trusteddomain.org/opendmarc/"
arch="all"
license="BSD-3-Clause Sendmail"
makedepends="libmilter-dev libspf2-dev"
pkgusers="$pkgname"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-dev $pkgname-libs $pkgname-openrc"
source="https://downloads.sourceforge.net/project/$pkgname/$pkgname-$pkgver.tar.gz
	netdb_defines.patch
	fix-153-duplicate-dkim-auth_result-sections.patch
	fix-193-sql-strict-mode-compatibility.patch
	dmarcfail-fix-shebang.patch
	config-defaults.patch
	$pkgname.initd
	"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare
	update_config_guess
	update_config_sub
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-installdir=/usr \
		--with-spf \
		--with-spf2-lib=/usr/lib \
		--with-spf2-include=/usr/include/spf2
	make
}

check() {
	cd "$builddir"
	opendmarc/opendmarc -V
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install

	cd "$pkgdir"

	install -m 644 -D "$builddir"/opendmarc/opendmarc.conf.sample \
		./etc/$pkgname/opendmarc.conf
	install -m 755 -D "$srcdir"/$pkgname.initd ./etc/init.d/$pkgname
	install -m 750 -o $pkgusers -g mail -d ./var/spool/$pkgname

	# Not needed, standard SPDX licenses.
	rm -Rf ./usr/share/doc/$pkgname/LICENSE*
}

sha512sums="6045fb7d2be8f0ffdeca07324857d92908a41c6792749017c2fcc1058f05f55317b1919c67c780827dd7094ec8fff2e1fa4aeb5bab7ff7461537957af2652748  opendmarc-1.3.2.tar.gz
a6808ac27264c84a8f7210ccc67f03028bc3644542c4def30824e6342a3fb207615c7b4b21f38084523df0b4dd777fbb6e9d3802bb50b41d3c5b0ce29ebfeff7  netdb_defines.patch
90036e48151d054e43e68f739c4a9cb029b5a698910a566a59148673f9a3329ba7550038fba73538309bf7c43374615819f0351623f273c1ef139129fb2bc5fc  fix-153-duplicate-dkim-auth_result-sections.patch
b9b7ce647f58e28f28862aa70b43c23579c453ecf839fde57524826193b099c4865e1da0b97eb7bcccf169c9343fd8f1187de4bbad37e1920561c790ac0ca7c2  fix-193-sql-strict-mode-compatibility.patch
a8585104490d42ecb2acce40df2e36fc5ed6155fecb16a9de5606703b1b3f5fc7f84f2933350fa3ff8f7da133bc251f30dc33b9c1310bc64e801179de68df026  dmarcfail-fix-shebang.patch
ea19017a1e2cab4fe388bca45f44f2f3d71c3212e7f5b312e13e0b7af7cd4180bf5ec1e441e65f0ac33e8d98241b4d980a56fe8afc16a443d304cfab06d2bd95  config-defaults.patch
db4a9c79bbf4c54ae70a61d1501b1fb044b2242b43b82b34365b1c1e45429290f3aa89a78711e9fae5518753ddb3e15de2ef68118dae275ed6a6d6be9b2c03ec  opendmarc.initd"
